import { Role } from "src/views/role/entities/role.entity";
import { User } from "src/views/users/entities/user.entity";
import { Column, Entity, ManyToMany, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";

@Entity('menus')
export class Menu {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  type: number;

  @Column()
  name: string;

  @Column()
  parent_id: number;

  @Column()
  code: string;

  @Column()
  updateTime: Date;

  @ManyToMany(type => Role, role => role.menus)
  role: Role

  @ManyToOne(type => User, user => user.menus)
  user: User

  @OneToMany(type => Menu, menu => menu.children)
  parent: Menu;

  @ManyToOne(type => Menu, menu => menu.parent)
  children: Menu[];

}
